home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-11 | 9.0 KB | 467 lines | [TEXT/CWIE] |
- // CModalText.cp -- dialog methods
-
- #include "CModalText.h"
-
- #include <UEnvironment.h>
- #include <UReanimator.h>
- #include <URegistrar.h>
- #include <LStream.h>
- #include <LTabGroup.h>
- #include <LPushButton.h>
- #include <LAMPushButtonImp.h>
- #include <LGAPushButtonImp.h>
- #include <LEditText.h>
- #include <LAMEditTextImp.h>
- #include <LGAEditTextImp.h>
- #include <LScrollerView.h>
- #include <LScrollBar.h>
- #include <LAMTrackActionImp.h>
- #include <LStdScrollBarImp.h>
- #include <LTextEditView.h>
- #include <CDoubleEditText.h>
- #include <LClock.h>
- #include <LAMControlImp.h>
- #include <CTextUtils.h>
-
- #include "DModalTextData.h"
- #include "EverythingCmds.h"
- #include <PP_Messages.h>
-
- const MessageT msgSmall = 'Smal';
- const MessageT msgX12345 = 'X145';
- const MessageT msgX12345e6 = 'X126';
- const MessageT msgPassword = 'Pasd';
- const MessageT msgDate = 'Date';
- const MessageT msgTime = 'Time';
-
- #define PPob_ModalTextID 211
- #define RidL_ModalTextID 211
-
- Boolean CModalText::sIsRegistered = false;
-
- //----------
- CModalText* CModalText::CreateModalText (
- LCommander* inSuperCommander,
- CommandT inCommand,
- DModalTextData* inData)
- {
- if (!sIsRegistered) {
- RegisterClass ();
- }
- CModalText* dlog;
- dlog = ((CModalText *)LWindow::CreateWindow(PPob_ModalTextID, inSuperCommander));
- dlog->mCommand = inCommand;
- dlog->SetFromData (inData);
-
- return dlog;
- }
-
- //----------
- #define RegisterClasses(AbstractClass,AMImpClass,GAImpClass) \
- RegisterClass_(AbstractClass); \
- if (useAppearance) { \
- RegisterClassID_(AMImpClass, AbstractClass::imp_class_ID); \
- } else { \
- RegisterClassID_(GAImpClass, AbstractClass::imp_class_ID); \
- }
-
- //----------
- void CModalText::RegisterClass ()
- {
- Boolean useAppearance = UEnvironment::HasFeature (env_HasAppearance);
-
- RegisterClass_(CModalText);
-
- // register the pane classes we use
- RegisterClasses (LPushButton, LAMPushButtonImp, LGAPushButtonImp);
- RegisterClasses (LEditText, LAMEditTextImp, LGAEditTextImp);
- RegisterClass_(LScrollerView);
- RegisterClasses (LScrollBar, LAMTrackActionImp, LStdScrollBarImp);
- RegisterClass_(LTextEditView);
- RegisterClasses (CDoubleEditText, LAMEditTextImp, LGAEditTextImp);
- RegisterClasses (LClock, LAMControlImp, LAMControlImp);
-
- sIsRegistered = true;
- }
-
- //----------
- CModalText::CModalText (
- LStream* inStream)
- : LGADialog (inStream)
- {
- mData = nil;
- }
-
- //----------
- CModalText::~CModalText()
- {
- delete mData;
- }
-
- //----------
- // This member function gets called once the containment hierarchy that contains
- // this pane has been built. It gives us a chance to get data members for
- // interesting subviews, and to do other operations now that our subviews exist.
- void CModalText::FinishCreateSelf()
- {
- LGADialog::FinishCreateSelf();
-
- mOKButton = (LPushButton*) FindPaneByID ('OK ');
-
- mSmallField = (LEditText*) FindPaneByID ('Smal');
- mSmallField->AddListener (this);
-
- mLargeField = (LTextEditView*) FindPaneByID ('Lare');
-
- mX12345Field = (LEditText*) FindPaneByID ('X145');
- mX12345Field->AddListener (this);
-
- mX12345e6Field = (CDoubleEditText*) FindPaneByID ('X126');
- mX12345e6Field->AddListener (this);
-
- mPasswordField = (LEditText*) FindPaneByID ('Pasd');
- mPasswordField->AddListener (this);
-
- mDateField = (LClock*) FindPaneByID ('Date');
- mDateField->AddListener (this);
-
- mTimeField = (LClock*) FindPaneByID ('Time');
- mTimeField->AddListener (this);
-
- mStyledField = (LTextEditView*) FindPaneByID ('Styd');
-
-
- LTabGroup* tabGroup = new LTabGroup(this);
- mSmallField->SetSuperCommander(tabGroup); // becomes the active field
- mLargeField->SetSuperCommander(tabGroup);
- mX12345Field->SetSuperCommander(tabGroup);
- mX12345e6Field->SetSuperCommander(tabGroup);
- mPasswordField->SetSuperCommander(tabGroup);
- mDateField->SetSuperCommander(tabGroup);
- mTimeField->SetSuperCommander(tabGroup);
- mStyledField->SetSuperCommander(tabGroup);
-
- UReanimator::LinkListenerToControls(this, this, RidL_ModalTextID);
- // the purpose is to "connect" self to whatever controls
- // that we want to "listen" to
-
- // any additional initialization for your dialog:
-
- }
-
- //----------
- void CModalText::SetFromData (
- DModalTextData* inData)
- {
- mData = inData;
- mData->AddListener (this);
-
- CTextUtils::SetText (mSmallField, mData->GetSmall2 ());
- CTextUtils::SetText (mLargeField, mData->GetLarge2 ());
- mX12345Field->SetValue (mData->GetX12346 ());
- mX12345e6Field->SetDValue (mData->GetX12345e7 ());
- CTextUtils::SetText (mPasswordField, mData->GetPassword2 ());
- {
- LongDateRec dateTime = mData->GetDate2 ();
- mDateField->SetLongDate (dateTime);
- }
- {
- LongDateRec dateTime = mData->GetTime2 ();
- mTimeField->SetLongDate (dateTime);
- }
- CTextUtils::SetText (mStyledField, mData->GetStyled2 ());
- }
-
- //----------
- DModalTextData* CModalText::GetData ()
- {
- mData->SetLarge2 ((CharsHandle)(mLargeField->GetTextHandle ()));
- mData->SetStyled2 ((CharsHandle)(mStyledField->GetTextHandle ()));
-
- return mData;
- }
-
- //----------
- void CModalText::DataChanged (
- long inDataID)
- {
- StopListening ();
-
- if (inDataID == idSmall2) {
- if (!mSmallField->IsTarget ()) {
- CTextUtils::SetText (mSmallField, mData->GetSmall2 ());
- }
- }
- if (inDataID == idLarge2) {
- CTextUtils::SetText (mLargeField, mData->GetLarge2 ());
- }
- if (inDataID == idX12346) {
- if (!mX12345Field->IsTarget ()) {
- mX12345Field->SetValue (mData->GetX12346 ());
- }
- }
- if (inDataID == idX12345e7) {
- if (!mX12345e6Field->IsTarget ()) {
- mX12345e6Field->SetDValue (mData->GetX12345e7 ());
- }
- }
- if (inDataID == idPassword2) {
- if (!mPasswordField->IsTarget ()) {
- CTextUtils::SetText (mPasswordField, mData->GetPassword2 ());
- }
- }
- if (inDataID == idDate2) {
- LongDateRec dateTime = mData->GetDate2 ();
- mDateField->SetLongDate (dateTime);
- }
- if (inDataID == idTime2) {
- LongDateRec dateTime = mData->GetTime2 ();
- mTimeField->SetLongDate (dateTime);
- }
- if (inDataID == idStyled2) {
- CTextUtils::SetText (mStyledField, mData->GetStyled2 ());
- }
-
- StartListening ();
- }
-
- //----------
- void CModalText::ListenToMessage (
- MessageT inMessage,
- void *ioParam)
- {
- switch (inMessage) {
- case msg_OK:
- GetSuperCommander()->ProcessCommand(-mCommand, this);
- break;
-
- case msg_Cancel:
- DoClose();
- break;
-
- case msgDataChanged:
- DataChanged ((long)ioParam);
- break;
-
- case msgSmall:
- {
- Str255 string;
-
- mSmallField->GetDescriptor (string);
- mData->SetSmall2 (string);
- }
- break;
-
- case msgX12345:
- mData->SetX12346 (mX12345Field->GetValue ());
- break;
-
- case msgX12345e6:
- mData->SetX12345e7 (mX12345e6Field->GetDValue ());
- break;
-
- case msgPassword:
- {
- Str255 string;
-
- mPasswordField->GetDescriptor (string);
- mData->SetPassword2 (string);
- }
- break;
-
- case msgDate:
- {
- LongDateRec dateTime;
-
- mDateField->GetLongDate (dateTime);
- mData->SetDate2 (dateTime);
- }
- break;
-
- case msgTime:
- {
- LongDateRec dateTime;
-
- mTimeField->GetLongDate (dateTime);
- mData->SetTime2 (dateTime);
- }
- break;
-
-
- default:
- ; // do something
- break;
- }
- }
-
- //----------
- Boolean CModalText::ObeyCommand (
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = true;
-
- if (inCommand < 0) {
- // modal dialog has finished
-
- switch (-inCommand) {
- }
-
- } else {
- switch (inCommand) {
-
- default:
- cmdHandled = LGADialog::ObeyCommand(inCommand, ioParam);
- break;
- }
- }
-
- return cmdHandled;
- }
-
- //----------
- void CModalText::FindCommandStatus (
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- outUsesMark = false;
-
- switch (inCommand) {
-
- // +++ Add cases here for the commands you handle
-
- default:
- LGADialog::FindCommandStatus(inCommand, outEnabled,
- outUsesMark, outMark, outName);
- break;
- }
- }
-
- // following functions will be obsoleted
- // retained only for backwards compatibility
- //----------
- void
- CModalText::GetSmallFieldString (
- Str255 str)
- {
- mSmallField->GetDescriptor (str);
- }
-
- //----------
- void
- CModalText::SetSmallFieldString (
- ConstStr255Param str)
- {
- mSmallField->SetDescriptor (str);
- }
-
- /*
- //----------
- Ptr
- CModalText::GetLargeFieldText ()
- {
- }
-
- //----------
- void
- CModalText::SetLargeFieldText (
- Ptr str)
- {
- }
- */
-
- //----------
- Int32
- CModalText::GetX12345FieldValue ()
- {
- return mX12345Field->GetValue ();
- }
-
- //----------
- void
- CModalText::SetX12345FieldValue (
- Int32 inNum)
- {
- mX12345Field->SetValue (inNum);
- }
-
- //----------
- double
- CModalText::GetX12345e6FieldValue ()
- {
- return mX12345e6Field->GetDValue ();
- }
-
- //----------
- void
- CModalText::SetX12345e6FieldValue (
- double inNum)
- {
- mX12345e6Field->SetDValue (inNum);
- }
-
- //----------
- void
- CModalText::GetPasswordFieldString (
- Str255 str)
- {
- mPasswordField->GetDescriptor (str);
- }
-
- //----------
- void
- CModalText::SetPasswordFieldString (
- ConstStr255Param str)
- {
- mPasswordField->SetDescriptor (str);
- }
-
- /*
- //----------
- Date
- CModalText::GetDateFieldDate ()
- {
- }
-
- //----------
- void
- CModalText::SetDateFieldDate (
- Date str)
- {
- }
- */
-
- /*
- //----------
- Date
- CModalText::GetTimeFieldDate ()
- {
- }
-
- //----------
- void
- CModalText::SetTimeFieldDate (
- Date str)
- {
- }
- */
-
- /*
- //----------
- Ptr
- CModalText::GetStyledFieldText ()
- {
- }
-
- //----------
- void
- CModalText::SetStyledFieldText (
- Ptr str)
- {
- }
- */
-
-